package tech.aichan.AiQA.model.vo;

import tech.aichan.AiQA.model.entity.User;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.Date;
/**
 * @author mengyu
 * @date 2024/03/03 9:43
 * Login用户视图
 */
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LoginUserVO {
    /**
     * id
     */
    private Long id;
    /**
     * 用户昵称
     */
    private String userName;

    /**
     * 用户头像
     */
    private String userAvatar;

    /**
     * 用户简介
     */
    private String userProfile;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;

    private static final long serialVersionUID = 1L;

    // JWT Token
    private String token;

    public static LoginUserVO getLoginUserVO(User user, String token){
        if (user == null) {
            return null;
        }
        LoginUserVO loginUserVO = new LoginUserVO();
        BeanUtils.copyProperties(user, loginUserVO);
        loginUserVO.setToken(token);
        return loginUserVO;
    }

}
